package Adapter.Before;

/**
 * Here we get a monster class from someone else. It has the
 * functionality that we need but it was created completely differently.
 * We could refactor it but that could be a problem at times because we
 * may have to change a large amount of classes.
 */
public class Game
{
    public static void main( String[] args )
    {
        Monster monster = new OurMonster();
        monster.takesDamage( 25 );

    }
}

interface Monster
{
    void takesDamage( int damage );
    int  givesDamage();
    boolean isTimeToAttack();
}

class OurMonster implements Monster
{
    int life = 100;

    public void takesDamage( int damage )
    {
        life = life - damage;
    }

    public int givesDamage()
    {
        return 25;
    }

    public boolean isTimeToAttack()
    {
        return false;
    }
}

/**
 * This Monster class simply can't work with our code. He does the same things
 * but his methods are different. Many times we get code from others that
 * simply cannot be easily refactored (such as precompiled libraries), so it makes
 * more sense to simply adapt them.
 */
class MegaMonster
{
    int life = 100;

    public int attacks()
    {
        return 35;
    }

    public void getsHit( int damage )
    {
        life = life - damage;
    }
}
